package leetcode.code2091;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int minimumDeletions(int[] nums) {
		int max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
		int maxi = 0, mini = 0;
		int len = nums.length;
		for (int i = 0; i < len; i++) {
			int num = nums[i];
			if (num > max) {
				max = num;
				maxi = i;
			}
			if (num < min) {
				min = num;
				mini = i;
			}
		}
		int l = Math.min(maxi, mini);
		int r = Math.max(maxi, mini);
		return Math.min(Math.min(r + 1, len - l), l + 1 + len - r);
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
